<div class="fm-content">
    <div class="title">
        <i nz-icon [type]="'desktop'"></i> &nbsp;&nbsp;指标数据
    </div>
    <div class="clwork">
        <div class="top">
            <input nz-input placeholder="名称" class="fm-input first-input"
                [(ngModel)]="fs.queryObject['indexname:like']" />
            <nz-button-group class="fm-search-input">
                <button nz-button nzType="primary" (click)="fs.loadData(true)">查询</button>
                <button nz-button (click)="fs.resetQueryObject() && fs.loadData(true)">重置</button>
            </nz-button-group>
            <div class="tool-right">
                <nz-button-group>
                    <button nz-button [nzType]="'primary'" (click)="fs.addRow()">新增</button>
                </nz-button-group>
            </div>
        </div>

        <div class="left top-left">
            <nz-tree #treeCom nzAsyncData (nzClick)="fs.loadDataEx($event.node.key)"
                [nzData]="columnTypeDic.treeDatas" (nzExpandChange)="columnTypeDic.expand($event)">
            </nz-tree>
        </div>

        <div class="right top-right">
            <div class="table">
                <nz-table nzSize="middle" nzShowSizeChanger [nzShowPagination]="false"
                    [nzFrontPagination]="false" [nzData]="fs.datas" [nzLoading]="fs.isLoading || fs.isDeleing">
                    <thead (nzSortChange)="fs.sort($event)" nzSingleSort>
                        <tr>
                            <th>名称</th>
                            <th>政区</th>
                            <th>年份</th>
                            <th>月份</th>
                            <th>数据值</th>
                            <th>有效</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <ng-template ngFor let-data [ngForOf]="fs.datas">
                            <ng-template ngFor let-item [ngForOf]="fs.expandDataCache[data.id]">
                                <tr *ngIf="(item.parent&&item.parent.expand)||!(item.parent)">
                                    <td [nzIndentSize]="item.level*20" [nzShowExpand]="!item.leaf"
                                        [(nzExpand)]="item.expand" (nzExpandChange)="fs.collapse(item,$event)">
                                        {{item.indexname}}
                                    </td>
                                    <td>{{item.adminname}}</td>
                                    <td>{{item.year}}</td>
                                    <td>{{item.month}}</td>
                                    <td>{{item.value}}</td>
                                    <td>{{item.valid | boolReform}}</td>
                                    <td>
                                        <a *ngIf="!item.leaf" (click)="fs.addRow(item)" class="form-button">新增子项</a>
                                        <a (click)="fs.editRow(item)" class="form-button">编辑</a>
                                        <a nz-popconfirm nzTitle="确认删除选择项?" (nzOnConfirm)="fs.delEntity(item)"
                                            nzPlacement="bottomRight" class="form-button">删除</a>
                                    </td>
                                </tr>
                            </ng-template>
                        </ng-template>
                    </tbody>
                </nz-table>
            </div>
        </div>

        <nz-modal nzWidth='830' nzTitle="编辑" [nzMaskClosable]='false' [nzFooter]="null" [(nzVisible)]="fs.isEditVisible"
            (nzOnCancel)="fs.closeEdit()">
            <form nz-form [nzLayout]="'inline'">
                <div nz-row [nzGutter]="24">
                    <div nz-col [nzSpan]="12">
                        <nz-form-item>
                            <nz-form-label nzRequired class="form-label">名称</nz-form-label>
                            <nz-form-control class="form-control"
                                [nzValidateStatus]="indexname.invalid?'error':'success'" nzHasFeedback>
                                <input nz-input required [(ngModel)]="fs.er.indexname" id="indexname" name="indexname"
                                    #indexname="ngModel">
                            </nz-form-control>
                        </nz-form-item>
                    </div>
                    <div nz-col [nzSpan]="12">
                        <nz-form-item>
                            <nz-form-label nzRequired class="form-label">数据值</nz-form-label>
                            <nz-form-control class="form-control" [nzValidateStatus]="value.invalid?'error':'success'"
                                nzHasFeedback>
                                <nz-input-number required [(ngModel)]="fs.er.value" name="value" [nzMin]="0"
                                    #value="ngModel" [nzStep]="1" class="form-control">
                                </nz-input-number>
                            </nz-form-control>
                        </nz-form-item>
                    </div>
                </div>
                <div nz-row [nzGutter]="24">
                    <div nz-col [nzSpan]="12">
                        <nz-form-item>
                            <nz-form-label nzRequired class="form-label">政区名称</nz-form-label>
                            <nz-form-control class="form-control"
                                [nzValidateStatus]="adminname.invalid?'error':'success'" nzHasFeedback>
                                <input nz-input required [(ngModel)]="fs.er.adminname" id="adminname" name="adminname"
                                    #adminname="ngModel">
                            </nz-form-control>
                        </nz-form-item>
                    </div>
                    <div nz-col [nzSpan]="12">
                        <nz-form-item>
                            <nz-form-label nzRequired class="form-label">政区值</nz-form-label>
                            <nz-form-control class="form-control" [nzValidateStatus]="adminid.invalid?'error':'success'"
                                nzHasFeedback>
                                <input nz-input required [(ngModel)]="fs.er.adminid" id="adminid" name="adminid"
                                    #adminid="ngModel">
                            </nz-form-control>
                        </nz-form-item>
                    </div>
                </div>
                <div nz-row [nzGutter]="24">
                    <div nz-col [nzSpan]="12">
                        <nz-form-item>
                            <nz-form-label nzRequired class="form-label">年份</nz-form-label>
                            <nz-form-control class="form-control" [nzValidateStatus]="year.invalid?'error':'success'">
                                <nz-input-number required [(ngModel)]="fs.er.year" name="year" [nzMin]="1"
                                    #year="ngModel" [nzStep]="1" class="form-control">
                                </nz-input-number>
                            </nz-form-control>
                        </nz-form-item>
                    </div>
                    <div nz-col [nzSpan]="12">
                        <nz-form-item>
                            <nz-form-label nzRequired class="form-label">月份</nz-form-label>
                            <nz-form-control class="form-control" [nzValidateStatus]="month.invalid?'error':'success'">
                                <nz-input-number required [(ngModel)]="fs.er.month" name="month" [nzMin]="1"
                                    [nzMax]="12" #month="ngModel" [nzStep]="1" class="form-control">
                                </nz-input-number>
                            </nz-form-control>
                        </nz-form-item>
                    </div>
                </div>
                <div nz-row [nzGutter]="24">
                    <div nz-col [nzSpan]="12">
                        <nz-form-item>
                            <nz-form-label nzRequired class="form-label">排序</nz-form-label>
                            <nz-form-control class="form-control" [nzValidateStatus]="order.invalid?'error':'success'">
                                <nz-input-number required [(ngModel)]="fs.er.order" name="order" [nzMin]="1"
                                    #order="ngModel" [nzStep]="1" class="form-control">
                                </nz-input-number>
                            </nz-form-control>
                        </nz-form-item>
                    </div>
                    <div nz-col [nzSpan]="12">
                        <nz-form-item>
                            <nz-form-label class="form-label">单位</nz-form-label>
                            <nz-form-control class="form-control">
                                <input nz-input [(ngModel)]="fs.er.unit" id="unit" name="unit" #unit="ngModel" />
                            </nz-form-control>
                        </nz-form-item>
                    </div>
                </div>
                <div nz-row [nzGutter]="24">
                    <div nz-col [nzSpan]="12">
                        <nz-form-item>
                            <nz-form-label class="form-label">属性</nz-form-label>
                            <nz-form-control class="form-control">
                                <label nz-checkbox [(ngModel)]="fs.er.valid" name="valid">有效</label>
                                <label nz-checkbox [(ngModel)]="fs.er.leaf" name="leaf">尾节点</label>
                            </nz-form-control>
                        </nz-form-item>
                    </div>
                </div>
                <div nz-row [nzGutter]="24">
                    <div nz-col [nzSpan]="24" class="form-button-align">
                        <button nz-button nzType="default" (click)="fs.closeEdit()" class="form-button">取消</button>
                        <button nz-button nzType="primary"
                            [disabled]='indexname.invalid || value.invalid|| adminname.invalid || adminid.invalid || year.invalid || month.invalid || order.invalid'
                            (click)="fs.save()" [nzLoading]="fs.isSaveing">保存</button>
                    </div>
                </div>
            </form>
        </nz-modal>
    </div>
</div>